package com.plugins.http;

import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import com.iclient.dao.service.ImgService;
import com.plugins.qiniu.ImgTool;

public class FileUtils {
	
	/**
	 * 下载jpg文件
	 * @param imgService
	 * @param inputStream
	 */
	public static String readImg(ImgService imgService, InputStream inputStream){
		try{
			File storeFile = new File("img.jpg");  
			FileOutputStream output = new FileOutputStream(storeFile);  
			if(inputStream != null) {
				byte b[] = new byte[1024];
				int j = 0;
				while( (j = inputStream.read(b))!=-1){
					output.write(b,0,j);
				}
			}
			output.flush();
			output.close();
			return ImgTool.upload();
		}catch(Exception ee){
			ee.printStackTrace();
		}
		return null;
	}

}
